// Copyright 2021 Guoyoko. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "SWDetailNode.h"
#include "SlateBasics.h"


class FSWDetailBuilder : public TSharedFromThis<FSWDetailBuilder>
{
public:
	FSWDetailBuilder() {}
	~FSWDetailBuilder() {}

	/*-> Add a category that can be expanded*/
	FSWDetailNode& AddCategory(FName InCategoryName, FName InCategoryDisplayName = "CategoryDisplayName", TSharedPtr<SWidget> InNodeWidget = nullptr);

	TSharedPtr<SWidget> BuildDetail();

private:
	TSharedRef<ITableRow> OnGenerateRowForTree(TSharedPtr<FSWDetailNode> InItem, const TSharedRef<STableViewBase>& OwnerTable);

	void OnGetChildrenForTree(TSharedPtr<FSWDetailNode> InParent, TArray<TSharedPtr<FSWDetailNode>>& OutChildren);

private:
	TArray<TSharedPtr<FSWDetailNode>> TreeSource;
	TSharedPtr<STreeView<TSharedPtr<FSWDetailNode>>> TreeView;
};

